package org.tysite.tyservice.example.validation.dto;

import org.hibernate.validator.constraints.URL;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 演示常用信息的属性验证
 * @author tysite
 * @date 2020/3/4 0004 21:25
 */
public class UserInfoDemoDTO implements Serializable {
    
    private static final long serialVersionUID = 8188224636645945353L;
    
    private enum SexEnum {
        /** 男 */
        MALE,
        /** 女 */
        FEMALE
    }
    
    /** 主键ID */
    private Integer id;
    
    /** 用户名 */
    @NotBlank(message = "请输入用户名")
    @Size(min = 3, max = 20, message = "用户名长度必须在3~20之间")
    private String username;
    
    /** 名称 */
    @NotBlank(message = "请输入姓名")
    @Size(min = 2, max = 20, message = "姓名长度必须在2~20之间")
    private String name;
    
    /** 资源名称 */
    @NotBlank(message = "请输入资源名称")
    @Size(max = 50, message = "资源名称长度必须在1~50之间")
    private String resourceName;
    
    /** 文本域 */
    @NotBlank(message = "请输入资源简介")
    @Size(max = 1000, message = "文本域长度必须在1~1200之间")
    private String textField;
    
    /** 密码 */
    @NotBlank(message = "请输入密码")
    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,20}",
        message = "密码长度8~20位，必须包含数字、字母(大小写各一个)、特殊字符")
    private String password;
    
    /** 性别 */
    private SexEnum genders;
    
    /** 邮箱 */
    @Email(message = "请输入正确的邮箱地址")
    private String email;
    
    /** 手机号码 */
    @Pattern(regexp = "^1[3|4|5|8][0-9]\\d{8}$", message = "请输入正确的手机号码")
    private String phone;
    
    /** 存款 */
    @Digits(integer = 14, fraction = 2, message = "请输入有效的金额")
    private Double deposit;
    
    /** 出生日期 */
    @Past(message = "请输入正确的出生日期")
    private Date birthday;
    
    /** 身高 */
    @NotNull(message = "请填写您的身高")
    @DecimalMin(value = "44.7", message = "请填写有效的身高")
    private Float stature;
    
    /** 爱好 */
    @Valid
    private List<AmateurDTO> amateur;
    
    /** 博客 */
    @URL
    private String blogs;
    
    public Integer getId() {
        return id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getResourceName() {
        return resourceName;
    }
    
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }
    
    public String getTextField() {
        return textField;
    }
    
    public void setTextField(String textField) {
        this.textField = textField;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }

    public SexEnum getGenders() {
        return genders;
    }
    
    public void setGenders(SexEnum genders) {
        this.genders = genders;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public Double getDeposit() {
        return deposit;
    }
    
    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }
    
    public Date getBirthday() {
        return birthday;
    }
    
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    
    public Float getStature() {
        return stature;
    }
    
    public void setStature(Float stature) {
        this.stature = stature;
    }
    
    public List<AmateurDTO> getAmateur() {
        return amateur;
    }
    
    public void setAmateur(List<AmateurDTO> amateur) {
        this.amateur = amateur;
    }
    
    public String getBlogs() {
        return blogs;
    }
    
    public void setBlogs(String blogs) {
        this.blogs = blogs;
    }
    
    @Override
    public String toString() {
        return "UserInfoDemoDTO{" +
            "id=" + id +
            ", username='" + username + '\'' +
            ", name='" + name + '\'' +
            ", resourceName='" + resourceName + '\'' +
            ", textField='" + textField + '\'' +
            ", password='" + password + '\'' +
            ", genders=" + genders +
            ", email='" + email + '\'' +
            ", phone='" + phone + '\'' +
            ", deposit=" + deposit +
            ", birthday=" + birthday +
            ", stature=" + stature +
            ", amateur=" + amateur +
            ", blogs='" + blogs + '\'' +
            '}';
    }
}
